#include <iostream>
#include <compare>

class Widget {
public:
    int value;
    int priority;

    Widget(int v, int p) : value(v), priority(p) {}

    // 自定义三向比较运算符的逻辑
    auto operator<=>(const Widget& other) const {
        if (auto p = priority <=> other.priority; p != 0) {
            return p; // 如果优先级不同，根据优先级比较结果返回
        }
        return value <=> other.value; // 如果优先级相同，根据值比较结果返回
    }
};

int main() {
    Widget w1(10, 2), w2(20, 1);

    auto result = w1 <=> w2;
    if (result < 0) {
        std::cout << "w1 is less important or has a lower value than w2" << std::endl;
    } else if (result == 0) {
        std::cout << "w1 is equal to w2" << std::endl;
    } else if (result > 0) {
        std::cout << "w1 is more important or has a higher value than w2" << std::endl;
    }
}